\doxysection{HT04.\+h}
\hypertarget{_h_t04_8h_source}{}\label{_h_t04_8h_source}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/motor/HTmotor/HT04.h@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/motor/HTmotor/HT04.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#ifndef\ HT04\_H}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#define\ HT04\_H}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <stdint.h>}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}bsp\_can.h"{}}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{controller_8h}{controller.h}}"{}}}
\DoxyCodeLine{00007\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{motor__def_8h}{motor\_def.h}}"{}}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#include\ "{}daemon.h"{}}}
\DoxyCodeLine{00009\ }
\DoxyCodeLine{00010\ \textcolor{preprocessor}{\#define\ HT\_MOTOR\_CNT\ 4}}
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#define\ CURRENT\_SMOOTH\_COEF\ 0.9f}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#define\ SPEED\_BUFFER\_SIZE\ 5}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#define\ HT\_SPEED\_BIAS\ -\/0.0109901428f\ }\textcolor{comment}{//\ 电机速度偏差,单位rad/s}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#define\ TORQUE\_COEF\_HT\ 3.5\ \ }\textcolor{comment}{//\ 扭矩系数,单位N.m/A}}
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00016\ \textcolor{preprocessor}{\#define\ P\_MIN\ -\/95.5f\ }\textcolor{comment}{//\ Radians}}
\DoxyCodeLine{00017\ \textcolor{preprocessor}{\#define\ P\_MAX\ 95.5f}}
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#define\ V\_MIN\ -\/45.0f\ }\textcolor{comment}{//\ Rad/s}}
\DoxyCodeLine{00019\ \textcolor{preprocessor}{\#define\ V\_MAX\ 45.0f}}
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#define\ T\_MIN\ -\/18.0f\ }\textcolor{comment}{//\ N·m}}
\DoxyCodeLine{00021\ \textcolor{preprocessor}{\#define\ T\_MAX\ 18.0f}}
\DoxyCodeLine{00022\ \textcolor{preprocessor}{\#define\ KP\_MIN\ 0.0f\ }\textcolor{comment}{//\ N-\/m/rad}}
\DoxyCodeLine{00023\ \textcolor{preprocessor}{\#define\ KP\_MAX\ 500.0f}}
\DoxyCodeLine{00024\ \textcolor{preprocessor}{\#define\ KD\_MIN\ 0.0f\ }\textcolor{comment}{//\ N-\/m/rad/s}}
\DoxyCodeLine{00025\ \textcolor{preprocessor}{\#define\ KD\_MAX\ 5.0f}}
\DoxyCodeLine{00026\ }
\DoxyCodeLine{00027\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\textcolor{comment}{//\ HT04}}
\DoxyCodeLine{00028\ \{}
\DoxyCodeLine{00029\ \ \ \ \ \textcolor{keywordtype}{float}\ total\_angle;\ \textcolor{comment}{//\ 角度为多圈角度,范围是-\/95.5\string~95.5,单位为rad}}
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{keywordtype}{float}\ last\_angle;}
\DoxyCodeLine{00031\ }
\DoxyCodeLine{00032\ \ \ \ \ \textcolor{keywordtype}{float}\ speed\_rads;}
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{keywordtype}{float}\ speed\_buff[SPEED\_BUFFER\_SIZE];}
\DoxyCodeLine{00034\ }
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keywordtype}{float}\ real\_current;}
\DoxyCodeLine{00036\ }
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{keywordtype}{float}\ feed\_dt;}
\DoxyCodeLine{00038\ \ \ \ \ uint32\_t\ feed\_cnt;}
\DoxyCodeLine{00039\ \}\ \mbox{\hyperlink{struct_h_t_motor___measure__t}{HTMotor\_Measure\_t}};}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00041\ \textcolor{comment}{/*\ HT电机类型定义*/}}
\DoxyCodeLine{00042\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00043\ \{}
\DoxyCodeLine{00044\ \ \ \ \ \mbox{\hyperlink{struct_h_t_motor___measure__t}{HTMotor\_Measure\_t}}\ measure;}
\DoxyCodeLine{00045\ }
\DoxyCodeLine{00046\ \ \ \ \ \mbox{\hyperlink{struct_motor___control___setting__s}{Motor\_Control\_Setting\_s}}\ motor\_settings;}
\DoxyCodeLine{00047\ }
\DoxyCodeLine{00048\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}}\ current\_PID;}
\DoxyCodeLine{00049\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}}\ speed\_PID;}
\DoxyCodeLine{00050\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}}\ angle\_PID;}
\DoxyCodeLine{00051\ \ \ \ \ \textcolor{keywordtype}{float}\ *other\_angle\_feedback\_ptr;}
\DoxyCodeLine{00052\ \ \ \ \ \textcolor{keywordtype}{float}\ *other\_speed\_feedback\_ptr;}
\DoxyCodeLine{00053\ \ \ \ \ \textcolor{keywordtype}{float}\ *speed\_feedforward\_ptr;}
\DoxyCodeLine{00054\ \ \ \ \ \textcolor{keywordtype}{float}\ *current\_feedforward\_ptr;}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keywordtype}{float}\ pid\_ref;}
\DoxyCodeLine{00056\ }
\DoxyCodeLine{00057\ \ \ \ \ Motor\_Working\_Type\_e\ stop\_flag;\ \textcolor{comment}{//\ 启停标志}}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \ \ \ \ CANInstance\ *motor\_can\_instace;}
\DoxyCodeLine{00060\ }
\DoxyCodeLine{00061\ \ \ \ \ DaemonInstance\ *motor\_daemon;}
\DoxyCodeLine{00062\ \ \ \ \ uint32\_t\ lost\_cnt;}
\DoxyCodeLine{00063\ \}\ \mbox{\hyperlink{struct_h_t_motor_instance}{HTMotorInstance}};}
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00065\ \textcolor{comment}{/*\ HT电机模式,初始化时自动进入CMD\_MOTOR\_MODE*/}}
\DoxyCodeLine{00066\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00067\ \{}
\DoxyCodeLine{00068\ \ \ \ \ CMD\_MOTOR\_MODE\ =\ 0xfc,\ \ \ \textcolor{comment}{//\ 使能,会响应指令}}
\DoxyCodeLine{00069\ \ \ \ \ CMD\_RESET\_MODE\ =\ 0xfd,\ \ \ \textcolor{comment}{//\ 停止}}
\DoxyCodeLine{00070\ \ \ \ \ CMD\_ZERO\_POSITION\ =\ 0xfe\ \textcolor{comment}{//\ 将当前的位置设置为编码器零位}}
\DoxyCodeLine{00071\ \}\ HTMotor\_Mode\_t;}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00079\ \mbox{\hyperlink{struct_h_t_motor_instance}{HTMotorInstance}}\ *HTMotorInit(\mbox{\hyperlink{struct_motor___init___config__s}{Motor\_Init\_Config\_s}}\ *config);}
\DoxyCodeLine{00080\ }
\DoxyCodeLine{00087\ \textcolor{keywordtype}{void}\ HTMotorSetRef(\mbox{\hyperlink{struct_h_t_motor_instance}{HTMotorInstance}}\ *motor,\ \textcolor{keywordtype}{float}\ ref);}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00093\ \textcolor{keywordtype}{void}\ HTMotorControlInit();}
\DoxyCodeLine{00094\ }
\DoxyCodeLine{00100\ \textcolor{keywordtype}{void}\ HTMotorStop(\mbox{\hyperlink{struct_h_t_motor_instance}{HTMotorInstance}}\ *motor);}
\DoxyCodeLine{00101\ }
\DoxyCodeLine{00107\ \textcolor{keywordtype}{void}\ HTMotorEnable(\mbox{\hyperlink{struct_h_t_motor_instance}{HTMotorInstance}}\ *motor);}
\DoxyCodeLine{00108\ }
\DoxyCodeLine{00115\ \textcolor{keywordtype}{void}\ HTMotorOuterLoop(\mbox{\hyperlink{struct_h_t_motor_instance}{HTMotorInstance}}\ *motor,\ \mbox{\hyperlink{motor__def_8h_a306d656c63a2d986e7aff57a0526395d}{Closeloop\_Type\_e}}\ type);}
\DoxyCodeLine{00116\ }
\DoxyCodeLine{00122\ \textcolor{keywordtype}{void}\ HTMotorCalibEncoder(\mbox{\hyperlink{struct_h_t_motor_instance}{HTMotorInstance}}\ *motor);}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ !HT04\_H\#define\ HT04\_H}}

\end{DoxyCode}
